package com.chf.job.service.impl;

import com.chf.job.dao.ReleaseInfoMapper;
import com.chf.job.pojo.ReleaseInfo;
import com.chf.job.service.ReleaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReleaseServiceImpl implements ReleaseService {
    @Autowired
    private ReleaseInfoMapper releaseInfoMapper;

    /**
     * 添加公司信息
     * @param id
     * @return
     */
    @Override
    public int addRelease(ReleaseInfo releaseInfo, Integer id, String email) {
        if (StringUtils.isBlank(releaseInfo.getCity()) || StringUtils.isBlank(releaseInfo.getMonthLow())) {
            return 0;
        }
        // 创建招聘信息实体类
        ReleaseInfo info = new ReleaseInfo();
        info.setCompanyId(id);
        info.setEmail(email);
        info.setPositClass(releaseInfo.getPositClass());
        info.setPositName(releaseInfo.getPositName());
        info.setDepart(releaseInfo.getDepart());
        info.setWorkXingzhi(releaseInfo.getWorkXingzhi());
        info.setMonthLow(releaseInfo.getMonthLow());
        info.setHightMonth(releaseInfo.getHightMonth());
        info.setCity(releaseInfo.getCity());
        info.setWorkExper(releaseInfo.getWorkExper());
        info.setEducation(releaseInfo.getEducation());
        info.setPositTemp(releaseInfo.getPositTemp());
        info.setPositDesc(releaseInfo.getPositDesc());
        info.setPositRequire(releaseInfo.getPositRequire());
        info.setPositOther(info.getPositOther());
        info.setBcEmail(releaseInfo.getBcEmail());
        info.setPositOther(releaseInfo.getPositOther());
        info.setAddress(releaseInfo.getAddress());
        info.setReceiverEmail(releaseInfo.getReceiverEmail());
        info.setPositStatus(1);
        info.setClickNum(1);
        return releaseInfoMapper.insertSelective(info);
    }

    /**
     * 修改职位状态
     * @param releaseId
     * @param status
     * @return
     */
    @Override
    public int updatePositStatus(Integer releaseId, Integer status) {
        ReleaseInfo releaseInfo = new ReleaseInfo();
        releaseInfo.setId(releaseId);
        releaseInfo.setPositStatus(status);
        return releaseInfoMapper.updateByPrimaryKeySelective(releaseInfo);
    }
}
